package top.jolyoulu.core.rdd.io

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @Author: JolyouLu
 * @Date: 2024/2/6 16:32
 * @Description
 */
object Spark01_RDD_Load {
  def main(args: Array[String]): Unit = {
    //准备环境 [*]:表示使用当前系统最大核
    val sparkConf: SparkConf = new SparkConf().setMaster("local[*]").setAppName("RDD")
    val sc: SparkContext = new SparkContext(sparkConf)

    val rdd1: RDD[String] = sc.textFile("output1")
    println(rdd1.collect().mkString(","))

    val rdd2: RDD[(String,Int)] = sc.objectFile("output2")
    println(rdd2.collect().mkString(","))

    val rdd3: RDD[(String, Int)] = sc.sequenceFile[String, Int]("output3")
    println(rdd3.collect().mkString(","))

    //关闭环境
    sc.stop()
  }
}
